package com.licq.ldoc.domain;

import org.apache.commons.lang.StringUtils;

/**
 * 
 * @author liujian
 *
 */
public abstract class AbstractNode implements Node {

	protected String name;
	
	protected Occurrencies occurrences;

	protected String comments;

	protected boolean required;
	
	protected boolean ignored;
	
	public String getName() {
		return name;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}
	
	public void appendComments(String comment) {
		comments = StringUtils.join(new String[]{comments, completeComment(comment)});
	}
	
	public void prependComments(String comment) {
		comments = StringUtils.join(new String[] {completeComment(comment), comments});
	}
	
	private String completeComment(String comment) {
		if (StringUtils.isNotBlank(comment) && !comment.endsWith(".")) {
			comment += ".";
		}
		return comment;
	}

	public Occurrencies getOccurrences() {
	    return occurrences;
	}

	public void setOccurrences(Occurrencies occurrences) {
		this.occurrences = occurrences;
	}

	public boolean isRequired() {
	    return required;
	}

	public void setRequired(boolean required) {
		this.required = required;
	}

	public boolean isIgnored() {
		return ignored;
	}

	public void setIgnored(boolean ignored) {
		this.ignored = ignored;
	}
	
}